Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor code cleanup #1079

Closed
wants to merge 9 commits into from
Closed

Minor code cleanup #1079

wants to merge 9 commits into from

Conversation

valzargaming
Copy link
Member

@valzargaming valzargaming commented Mar 25, 2023

Made some readability changes and moved the resolved/reject handling code into functions outside of the Deferred constructor, and used === instead of ==

@valzargaming
Copy link
Member Author

I think I fixed it now, should be good to test

$promise = coroutine([$handler, 'handle'], $data->d);
$promise->done([$deferred, 'resolve'], [$deferred, 'reject']);
$promise->done(&$onResolve, &$onReject);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$promise->done(&$onResolve, &$onReject);
$promise->done($onResolve, $onReject);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&$deferred was previously passed by reference, and these functions replace deferred

/** @var ExtendedPromiseInterface */

if (! $this->emittedInit && ! in_array($data->t, $parse)) {
$this->unparsedPackets[] = function () use (&$handler, &$onResolve, &$onReject, &$data) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you passing these as reference?

Copy link
Member Author

@valzargaming valzargaming Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

&$deferred was previously passed by reference, and these functions replace deferred

@valzargaming
Copy link
Member Author

Closing this for now due to being outdated by almost two years. A lot has changed with Promises v3 and I'd feel more comfortable remaking this PR from scratch than trying to update it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants